<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<include file="Public:meta" />
</head>
<body id="main_page">
<include file="Public:position" />
<div class="container"> 
      <form enctype="multipart/form-data" method="post" id="frm">
            <div class="table">
                   <div class="toolbars">
                        <li class="toolbar"><a id="btnSaveAll" href="{$Url}Add"  title="添加幻灯分组" target="_self">添加幻灯分组</a></li>
                        <li class="toolbar"><a id="selectall" onclick="CheckAll()"  title="全选">全选</a></li>
                        <li class="toolbar"><a id="del" onclick="BatchDel()" title="批量删除">删除</a></li>
                        <li class="toolbar"><a id="sortall" onclick="BatchSort()" title="批量排序">排序</a></li>
                    </div>
                    <table class="datatable" id="datatable">
                        <tr>
                            <th width="50px"  nowrap="nowrap">选中</th>
                            <th width="90px" >幻灯分组ID</th>
                            <th>幻灯分组名称</th> 
                            <th width="90px" >幻灯片数量</th>
                            <th width="90px" >幻灯分组排序</th>
                            <th width="120px" >幻灯分组属性</th>
                            <th style="text-align:left;width:150px;">操作</th>
                        </tr>  
                        <notempty name="BannerGroup">
                            <volist name="BannerGroup" id="lc">
                                <tr id="tr{$lc.BannerGroupID}">
                                    <td><eq name="lc.BannerCount" value="0"><input class="checkrow" type="checkbox" name="BannerGroupID[]" value="{$lc.BannerGroupID}" /></eq></td>
                                    <td>{$lc.BannerGroupID}</td>
                                    <td style="text-align:left; padding-left:5px;">{$lc.BannerGroupName}</td>
                                    <td style="color:blue;">{$lc.BannerCount}</td>
                                    <td>
                                    <input type="text" class='textinput' onclick="this.select()" style="width:65px" name="BannerGroupOrder[]" value="{$lc.BannerGroupOrder}" />
                                    <input type="hidden" class='textinput' name="BannerGroupOrderID[]" value="{$lc.BannerGroupID}" />
                                    </td>
                                    <td>
                                        <eq name="lc.IsSystem" value="1">
                                            <span style="color:#00F">系统</span>
                                        <else/>
                                            <span style="color:#000">自定义</span>
                                        </eq>
                                    </td>
                                    
                                    <td class="operator">
                                        <a style="float:left" href="{$Url}Modify/BannerGroupID/{$lc.BannerGroupID}" id="btnEdit">修改</a>
                                        <neq name="lc.IsSystem" value="1">
                                            <eq name="lc.BannerCount" value="0">
                                                <div class="btn-sep"></div>
                                                <a style="float:left" onclick="Del({$lc.BannerGroupID})" class="btnDel">删除</a>
                                            </eq>
                                        </neq>
                                    </td>
                                </tr>
                            </volist>
                        <else/>
                            <tr><td colspan="7" id="NoData">{$Think.lang.NoDataTip}</td></tr>
                        </notempty>                                  
                  </table>
                 <div class="tfoot">
                      <div id="notice"><b>说明：</b><span class="notice-item">如果幻灯分组存在幻灯片，则不能删除</span></div>
                 </div>
         </div>
	</form>
</div>
</body>
</html>
<script type="text/javascript">
function Del(id){
	$.confirm("{$Think.lang.DeleteTip}", function () {
		url = "{$Url}del/BannerGroupID/"+id;
		$.get(url, {}, DelComplete, "json");
	}, function () {
		return true;
	});
}

//回调函数
function DelComplete(data, textStatus){
	if (data.status == 1){
		$(data.data).css("display","none");
	}else{ 
		//删除失败
		ErrorBox(data.info);
	}
}

//批量删除
function BatchDel(){
	//var arrChk = $("input[name='InfoID[]'][checked]"); //在高速浏览器长度总是返回0
	var arrChk = $("input[name='BannerGroupID[]']");
	var n = 0;
	for(var i = 0; i < arrChk.length; i++){
		if(arrChk[i].checked) n++;
	}
	
	if( n == 0 ) {
		WarnBox("{$Think.lang.CheckDeleteTip}");
		return;
	}
	
	$.confirm("{$Think.lang.DeleteTip}", function () {
		$('#frm').attr("action", "__URL__/batchDel");
		$('#frm').submit();
	}, function () {
		return true;
	});
}

//排序
function BatchSort(){
	$.confirm("{$Think.lang.SortTip}", function () {
		$('#frm').attr("action", "__URL__/batchSort");
		$('#frm').submit();
	}, function () {
		return true;
	});
}	
</script>